package 树.easy;

/**
 * @author Lw中
 * @date 2020/11/1 10:04
 */
public class YiLingSi {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int x) {
            val = x;
        }
    }

    /**
     * 二叉树的最大深度
     * @param root
     * @return
     */
    /**
     * LWZ TODO : 2020/11/1 递归有点蒙
     */
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        } else {
            int leftHeight = maxDepth(root.left);
            int rightHeight = maxDepth(root.right);
            return Math.max(leftHeight, rightHeight) + 1;
        }
    }

    public static void main(String[] args) {

    }

}
